Python Deep Learning Projects by Matthew Lamons

Python Deep Learning Projects by Matthew Lamons
Author: Matthew Lamons
Language: eng
Format: epub
Tags: COM004000 - COMPUTERS / Intelligence (AI) and Semantics, COM037000 - COMPUTERS / Machine Theory, COM044000 - COMPUTERS / Neural Networks
Publisher: Packt Publishing
Published: 2018-10-31

The rescaling operation scales the pixel values to a range between 0 and 1.

The next step is to fit this generator on the train data:

train_datagen.fit(X_train)

Compiling the model


We need to define and compile the deep convolution model like so:

# define model

model = Sequential()

model.add(Conv2D(32, kernel_size=(3,3), input_shape=input_shape, activation = 'relu'))

model.add(MaxPool2D(2,2))

model.add(Dropout(0.2))

model.add(Conv2D(64, kernel_size=(3,3), activation = 'relu'))

model.add(MaxPool2D(2,2))

model.add(Dropout(0.2))

model.add(Conv2D(128, kernel_size=(3,3), activation = 'relu'))

model.add(MaxPool2D(2,2))

model.add(Dropout(0.2))

model.add(Flatten())

model.add(Dense(128, activation = 'relu'))

model.add(Dropout(0.2))

model.add(Dense(10, activation = 'softmax'))